﻿@using BonjourQuotation.UI.Models.AccountModel
@model ProfileViewModel

<script type="text/javascript">
    function GetAllProfileGrid()
    {
        if ($("#AllProfileGridCopy").length > 0) {
            $("#AllProfileGridCopy").remove();
        }
        var table = $('<table></table>');
        $("#LoadProfilePermissionsForm").append("<div id='AllProfileGridCopy' style='Display:None'></div>");
        $("#LoadProfilePermissionsForm .ProfileLineNo").each(function () {
            var columntr = $("<tr style='border: 1px solid black;border-collapse: collapse'></tr>");
            var rowLineNo = $("<td style='border: 1px solid black;border-collapse: collapse'></td>").html($(this).val());
            columntr.append(rowLineNo)
            var ProfileToolTabColumnNameParent = $(this).parent().parent();
            var ProfileToolTabColumnName = $("<td style='border: 1px solid black;border-collapse: collapse'></td>").html($("option:selected", ProfileToolTabColumnNameParent.find(".ProfileLineNoChangeDrop")).text());
            columntr.append(ProfileToolTabColumnName)
            table.append(columntr);
        });
        $('#AllProfileGridCopy').append(table);
    }
    $(document).on("copy", "#CopyAllProfile", function (e) {
        GetAllProfileGrid();
        var table = $("#AllProfileGridCopy");
        e.clipboardData.clearData();
        e.clipboardData.setData("text/html", table.html());
        e.preventDefault();
        $("#AllProfileGridCopy").remove();
    });
</script>
@using (@Html.BeginForm("SaveProfile", "Account", FormMethod.Post, new { id = "LoadProfilePermissionsForm" }))
{
    @Html.HiddenFor(model => model.Message, new { @id = "ProfileErrorMessage"})
    @Html.HiddenFor(model => model.ProfileID)
    <div id="ErrorMessagesDivPopUp">
            <label for="Validation" id="errorMessageClient" class="errorMessage"></label>
                @if (Model.Message != null)
        {
            @Html.LabelForModel(Model.Message, new { @class = "errorMessage", id = "errorMessageServer" })
        }
        </div>
<div class="pull-right">
        <div class="row form-row">
            <div class="ElementsPaddingRight30  col-lg-5">
                <div class="input-group" id="Profiledrop">
                    <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.Profile)</span>
                @Html.DropDownListFor(model => model.SelectedProfile, new SelectList(Model.Profile, "Value", "Text"), new { @class = "table_inputs_SmallPadding2 inpputgr form-control ProfileDrop ElementsForValidation", @id = "ProfileSelectedProfile" })
                </div>
            </div>
            <div class="ElementsPaddingRight30  col-lg-5">
                <div class="input-group">
                    <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ProfileName)</span>
                @Html.TextBoxFor(model => model.ProfileName, new { @class = "table_inputs_SmallPadding2 inpputgr form-control ElementsForValidation MaxLength50 Required ProfileToolElemnetsChange ProfileToolElemnetsChange ProfileNameChange" })
                </div>
            </div>
            <div class=" col-lg-2">
                <button class="btn14 btn50" type="button" id="CreateProfile">Create</button>
                <button class="btn14 btn50" type="button" id="EditeProfile" style = "Display:None">Edit</button>

            </div>
        </div>
        <div class="row form-row">
            <div class=" col-lg-6">
                <div class="input-group" id="Profiletooldrop" @((Model.Profile.Count > 0) ? null : new { @style = "Display:None" })>
                    <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ProfileTool)</span>
                @Html.DropDownListFor(model => model.SelectedProfileTool, new SelectList(Model.ProfileTool, "Value", "Text"), "Select", new { @class = "table_inputs_SmallPadding2 inpputgr form-control ProfileToolDrop" })
                </div>

            </div>
            <div class=" col-lg-6">
                <div class="input-group" id="Profiletooltabdrop" style="Display:None">
                    <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ProfileToolTab)</span>
                @Html.DropDownListFor(model => model.SelectedProfileToolTab, new SelectList(Model.ProfileToolTab, "Value", "Text"), "Select", new { @class = "table_inputs_SmallPadding2 inpputgr form-control ProfileToolTabDrop" })
                </div>
            </div>
        </div>
    </div>
    <div style="height:480px">
            <div id="ProfileToolTabColumnPermissionsGridDiv" style = "Display:None"></div>
        </div>
    <div class="SaveCancelDiv" style="padding-top:20px">
        <input type="button" id="CopyAllProfile" class="btn14 btn90" value="Copy Grid" style="display:none">
        <button class="btn14 btn50" type="button" onclick="$('#cboxClose').click()">Cancel</button>
        <button class="btn14 btn50" type="button" id="ProfileToolTabColumnPermissionsSaveBtn">Save</button>
    </div>
}



